<template>
	<view>
		<view class="fixed">
			<view class="cu-bar tabbar bg-black">
				<view @click="navToHome()" class="action" :class="action == 0 ? 'text-red':'text-gray'">
					<view>
						<uni-icons type="home" size="25" :color="action == 0 ? '#7468BE':'#000000'"></uni-icons>
					</view>
					储罐管理
				</view>
				<view @click="myTasks()" class="action" :class="action == 1 ? 'text-red':'text-gray'">
					<view>
						<uni-icons type="wallet-filled" size="25" :color="action == 1 ? '#7468BE':'#000000'"></uni-icons>
					</view>
					通信设备
				</view>
				<view @click="navToMy" class="action" :class="action == 2 ? 'text-red':'text-gray'" >
					<view>
						<uni-icons type="contact" size="25" :color="action == 2 ? '#7468BE':'#000000'"></uni-icons>
					</view>
					采集值维护
				</view>
				<view @click="navToMy" class="action" :class="action == 3 ? 'text-red':'text-gray'" >
					<view>
						<uni-icons type="contact" size="25" :color="action == 3 ? '#7468BE':'#000000'"></uni-icons>
					</view>
					系统管理
				</view>
			</view>
			<!-- 底部分享弹窗 -->
			<uni-popup style="position: fixed; width: 100%; z-index: 999999;" :show="couponStatus" position="bottom" @hidePopup="couponStatus = !couponStatus">
				<view class="uni-share" style="width: 90%; margin: auto;">
					<view style="background: #FFFFFF; border-radius: 20upx;">
						<view @click="navToSend(1)" class="butn">图片/视频</view>
						<view @click="navToSend(2)" class="butn" style="border-top: 1px solid #EEEEEE;">链接</view>
					</view>
					<view class="uni-share-btn" @click="couponStatus = !couponStatus">取消</view>
				</view>
			</uni-popup>
		</view>
		
	</view>
</template>
<script>
	// import Env from '@/util/Env.js';
	const locationUtils = require('@/util/location.js') // 引入工具类
	import uniPopup from './uni-popup/uni-popup.vue'
	export default {
		name:"foot",
		props:{
			action:{
				type:Number,
				default:0,
			}
		},
		components: {
			uniPopup
		},
		computed: {
			
		},
		data() {
			return {
				couponStatus: false,
			};
		},
		methods:{
			getUrlParams(href,name) {
			  var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
			  if (reg.test(href)) {
			    return unescape(RegExp.$2.replace(/\+/g, " "))
			  };
			  return "";
			},
			couponStatusone(){
				locationUtils.getLocation().then(resLocation => {
					console.log('当前所在位置的经纬度为：')
					console.log(resLocation)
					console.log(resLocation.latitude, resLocation.longitude)
				this.couponStatus = !this.couponStatus
				uni.showLoading({
					title:'数据加载中'
				})
				var that = this
				uni.scanCode({
				 success: function (res) {
					 console.log(res)
					 console.log('条码类型：' + res.scanType);
					 console.log('条码内容：' + res.result);
					 if(res.path){
						 // 劳务员工---绑定二维码  
						 that.$http.get(`/classesLaborPost/bind/${that.getUrlParams(res.path,'classesId')}/${that.getUrlParams(res.path,'laborId')}`,{},true).then(res => {
						 	console.log("------------绑定劳务员工二维码");
							if(res.code == 200){
						 		uni.hideLoading()
						 		uni.showToast({ title:res.msg, icon: 'none',duration: 1000 });
								that.$emit('updata')
						 	}else{
						 		uni.hideLoading()
						 		uni.showToast({ title:res.msg, icon: 'none',duration: 1000 });
						 	}
						 }).catch(err => {
						 	uni.showToast({ title: err.msg, icon: 'none',duration: 1000 });
						 	uni.hideLoading()
						 })
					 }else{
						 if(res.result.indexOf("staffUserSignIn") != -1){
							 //上、下班
							 if(res.result.indexOf("/0/") != -1){
								  that.$http.get(res.result + "/" + 114.13228 + "/" + 22.68830,{},true).then(res => {
									if(res.code == 200){
										uni.hideLoading()
										uni.showToast({ title:"签到成功!", icon: 'none' });
										that.$emit('updata')
									}else{
										uni.hideLoading()
										uni.showToast({title:res.msg,icon: 'none',duration:2000});
									}
								 }).catch(err => {
									 uni.hideLoading()
									uni.showToast({ title: err.msg, icon: 'none' });
								 })
							 }else if(res.result.indexOf("/1/") != -1){
								 that.$http.get(res.result + "/" + 114.13228 + "/" + 22.68830,{},true).then(res => {
									if(res.code == 200){
										uni.hideLoading()
										uni.showToast({ title:"签到成功!", icon: 'none' });
										that.$emit('updata')
									}else{
										uni.hideLoading()
										uni.showToast({title:res.msg,icon: 'none',duration:2000});
									}
								 }).catch(err => {
									 uni.hideLoading()
									uni.showToast({ title: err.msg, icon: 'none' });
								 })
							 }
								
						 }else{
							    that.$http.get(res.result,{},true).then(res => {
								console.log("------------绑定自有二维码");
								console.log(res);
								if(res.code == 200){
									uni.hideLoading()
									uni.showToast({ title:res.msg, icon: 'none',duration: 1000 });
									that.$emit('updata')
								}else{
									uni.hideLoading()
									uni.showToast({ title:res.msg, icon: 'none',duration: 1000 });
								}
								 }).catch(err => {
									uni.showToast({ title: err.msg, icon: 'none',duration: 1000 });
									uni.hideLoading()
								 })
						 }
						 
						 
						
					 }
				 },
				 fail: res => {
					console.log(res);
					uni.hideLoading()
				 }
				});
				})
			},
			myTasks(){
				uni.navigateTo({
					url: '../myTasks/myTasks'
				})
			},
			navToHome(){
				uni.reLaunch({
					url:"/pages/home/homePage"
				})
				// if(this.action == 1){
					
				// }
				// uni.showModal({
				// 	title: '功能待上线',
				// 	content: '请耐心等待...',
				// 	success: function(res) {
				// 		if (res.confirm) {
				// 			console.log('用户点击确定');
				// 		} else if (res.cancel) {
				// 			console.log('用户点击取消');
				// 		}
				// 	}
				// });
			},
			navToMy(){
				// uni.showModal({
				// 	title: '功能待上线',
				// 	content: '请耐心等待...',
				// 	success: function(res) {
				// 		if (res.confirm) {
				// 			console.log('用户点击确定');
				// 		} else if (res.cancel) {
				// 			console.log('用户点击取消');
				// 		}
				// 	}
				// });
					uni.reLaunch({
						url:'/pages/mine/mine'
					})
			}
		},
		onShow(){
			// console.log('--------------------')
		}
	}
</script>

<style lang="scss">
	@import "../colorui/main.css";
	/*每个页面公共css */
	.fixed {
		position: fixed;
		z-index: 98;
		bottom:0upx;
		width: 100%;
		box-shadow: 0 3px 10px 1px #bac3c3;
	}
	.bg-black {
		background-color: #FFFFFF;
		color: #000000;
	}
	.text-red{
		color: #7468BE;
	}
	.text-gray{
		color: #000000;
	}
	/* 底部分享 */
	.uni-share {
		display: flex;
		flex-direction: column;
	}
	.uni-share-btn {
		height: 90rpx;
		line-height: 90rpx;
		font-size: 14px;
		text-align: center;
		color: #666;
		background: #7468BE;
		border-radius: 20upx;
		margin: 20upx 0;
		color: #ffff;
	}
	.butn{
		font-size: 30upx; 
		font-weight: 400;
		height: 100upx;
		line-height: 100upx;
		text-align: center;
		width: 100%;
	}
</style>
